<template>
  <div class="auth-container">
    <el-card class="auth-card">
      <div class="auth-header">
        <div class="app-logo">
          <div class="logo-circle">APP</div>
        </div>
        <h2>授权请求</h2>
      </div>
      
      <div class="auth-content">
        <p>请为应用程序授权访问您的数据</p>
        
        <div class="permissions-list">
          <div class="permission-item">
            <el-icon><View /></el-icon>
            <span>查看设备信息</span>
          </div>
          <div class="permission-item">
            <el-icon><Setting /></el-icon>
            <span>控制设备状态</span>
          </div>
          <div class="permission-item">
            <el-icon><Bell /></el-icon>
            <span>接收设备通知</span>
          </div>
        </div>
        
        <div class="auth-buttons">
          <el-button type="info" @click="cancelAuth">取消</el-button>
          <el-button type="primary" @click="confirmAuth">授权</el-button>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import { View, Setting, Bell } from '@element-plus/icons-vue'

export default {
  components: { View, Setting, Bell },
  methods: {
    // 确认授权
    confirmAuth() {
      // 跳转回用户绑定页面，携带成功参数
      this.$router.replace({
        path: '/account',
        query: { success: 'true' }
      });
    },
    
    // 取消授权
    cancelAuth() {
      // 清除存储的品牌信息
      sessionStorage.removeItem('bindingBrand');
      
      // 直接返回原页面
      this.$router.back();
    }
  }
}
</script>

<style scoped>
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #f5f7fa;
}

.auth-card {
  width: 500px;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.app-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
}

.logo-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #409EFF;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
}

.auth-content {
  padding: 0 20px;
}

.auth-content p {
  text-align: center;
  color: #606266;
  margin-bottom: 25px;
  font-size: 16px;
}

.permissions-list {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 30px;
}

.permission-item {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  font-size: 15px;
}

.permission-item:last-child {
  margin-bottom: 0;
}

.permission-item .el-icon {
  margin-right: 10px;
  color: #409EFF;
  font-size: 18px;
}

.auth-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.auth-buttons .el-button {
  width: 120px;
}
</style>